<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <h3>{{title}}</h3>
    <div>
      <button @click="count--">-</button>
      <span>{{count}}</span>
      <button @click="count++">+</button>
    </div>
  </div>
  <script src="../vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        count: 100,
        title: '计数器'
      },
      methods: {},

      //1 创建阶段 准备数据
      beforeCreate() {
        console.log('响应式数据准备好之前', this.count); //输出的是 undefined
      },
      created() {
        //可以开始去发送初始化渲染的请求了
        console.log('响应式数据准备好之后', this.count);//输出的是 100
      },

      //2 挂载阶段 渲染模板

      beforeMount() {
        console.log('模板渲染之前', document.querySelector('h3').innerHTML); //输出的是{{title}}
      },
      mounted() {
        console.log('模板渲染之后', document.querySelector('h3').innerHTML);//输出的是计数器
      }
    })
  </script>
</body>

</html>